// ShmWriter.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "PersistentQ.h"

PersistentQ gPQ;

int main(int argc, char* argv[])
{
    bool bInitStat  =  false;
    do
    {    
        cout << "Going to open Q for writing"<<endl;

        bInitStat = gPQ.init(szFileName,eWriter);
        if (false == bInitStat)
        {
            break;
        }
        const int nRuncnt = 1024;
        for( int i = 0;i<nRuncnt;i++)
        {
			Data dt;
			memset(&dt,0,sizeof(Data));
#if defined _WIN32 || defined _WIN64
            SYSTEMTIME st;
            GetLocalTime(&st);
            sprintf_s(dt.acData,"value %d time is: %02d:%02d:%02d:%02d\n",i,st.wHour, st.wMinute,st.wSecond,st.wMilliseconds);
#elif defined   __linux__
			time_t rawtime;
			struct tm *tm;
			time( &rawtime );
			tm = localtime( &rawtime );
			sprintf(dt.acData,"value %d time is:%02d:%02d:%02d:%02d\n",i,tm->tm_hour, tm->tm_min,tm->tm_sec,0);
#endif
			bool bStat = gPQ.PushBack(dt);
			if (false ==bStat)
			{
		    }
        }
    } while(0);
    return 0;
}